
<div id="accountList">
    <form id="accountNewMember">
        <h1 class="title-big-01"><?=$LANG["label"]["CREATENEWUSER"];?></h1>
        <div class="clear group-table-2">
            <div class="table-management-2">
                <div class="row head clear">
                    <span><?=$LANG["label"]["INFORMATIONOFUSER"];?></span>
                </div>
                <div class="row clear">
                    <span class="col caption"><?=$LANG["label"]["USERNAME"];?> </span>
                    <span class="col">
                        <input type="text" value="" name="username">
                        <div class="notification"></div>
                    </span>
                </div>
                <div class="row clear">
                    <span class="col caption"><?=$LANG["label"]["PASSWORD"];?></span>
                    <span class="col">
                        <input type="password" value="" name="password">
                        <div class="notification"></div>
                    </span>
                </div>
                <div class="row clear">
                    <span class="col caption"><?=$LANG["label"]["REPASSWORD"];?> </span>
                    <span class="col">
                        <input type="password" value="" name="confirmPassword">
                        <div class="notification"></div>
                    </span>
                </div>
                <div class="row clear">
                    <span class="col caption"><?=$LANG["label"]["EMAIL"];?> </span>
                    <span class="col">
                        <input type="email" value="" name="email">
                        <div class="notification"></div>
                    </span>
                </div>
            </div>
            <div class="table-management-2">
                <div class="row head clear">
                    <span><?=$LANG["label"]["PERSONALINFORMATION"];?></span>
                </div>
                <div class="row clear">
                    <span class="col caption"><?=$LANG["label"]["FIRSTNAME"];?> </span>
                    <span class="col">
                        <input type="text" value="" name="firstName">
                        <div class="notification"></div>
                    </span>
                </div>
                <div class="row clear">
                    <span class="col caption"><?=$LANG["label"]["LASTNAME"];?> </span>
                    <span class="col">
                        <input type="text" value="" name="lastName">
                        <div class="notification"></div>
                    </span>
                </div>
                <div class="row clear">
                    <span class="col caption"><?=$LANG["label"]["GENDER"];?></span>
                    <span class="col">
                        <div class="radio">
                            <input type="radio" name="gender" value="1"> 
                            <span><?=$LANG["label"]["MALE"];?></span>
                        </div>
                        <div class="radio">
                            <input type="radio" name="gender" checked="" value="0"> 
                            <span><?=$LANG["label"]["FEMALE"];?></span>
                        </div>
                    </span>
                </div>
                <div class="row clear">
                    <span class="col caption"><?=$LANG["label"]["ADRESS"];?> </span>
                    <span class="col">
                        <textarea name="address"></textarea>
                        <div class="notification"></div>
                    </span>
                </div>
                <div class="row clear">
                    <span class="col caption"><?=$LANG["label"]["PHONE"];?> </span>
                    <span class="col">
                        <input type="text" value="" name="phone">
                        <div class="notification"></div>
                    </span>
                </div>
            </div>
        </div>

        <div class="row-group-submit-tbm2 clear">
            <input <?= (isset($_GET['role'])) ? '' : 'style="display:none"' ?> type="button" value="<?=$LANG["label"]["BACK"]; ?>" name="back" class="right" onclick="goBack();">
            <input type="button" value="<?=$LANG["label"]["CREATENEWUSER"];?>" name="submit" class="right"> 
        </div>
    </form>
</div>

<?php
$agentLog = $_SESSION['agentLog'];
$role = (isset($_GET['role'])) ? $_GET['role'] : $agentLog['Role'];
$parentid = (isset($_GET['parentid'])) ? $_GET['parentid'] : $agentLog['PlayerID'];
?>
<script>
    handleSelectedBox();
    var url = URL_LODE + '/View/agent-management-taikhoan.php';

    /* Create New Player */
    $('#accountNewMember input[name="submit"]').click(function() {
        $.ajax({
            url: url,
            type: 'POST',
            beforeSend: function() {
                mb.createloadingTable1('#contentManagement');
            },
            data: {
                tab: "createnewuser",
                action: 'createuser',
                username: $('#accountNewMember input[name="username"]').val(),
                password: $('#accountNewMember input[name="password"]').val(),
                repassword: $('#accountNewMember input[name="confirmPassword"]').val(),
                email: $('#accountNewMember input[name="email"]').val(),
                firstname: $('#accountNewMember input[name="firstName"]').val(),
                lastname: $('#accountNewMember input[name="lastName"]').val(),
                gender: $('#accountNewMember input[name="gender"]:checked').val(),
                address: $('#accountNewMember textarea[name="address"]').val(),
                phone: $('#accountNewMember input[name="phone"]').val(),
                level: '1',
                parentid: '<?= $parentid; ?>',
                role: '<?= intVal($role) - 1; ?>'
            },
            success: function(data) {
                openDialogMessage("Thông Báo", "Tạo người dùng thành công !");
            },
            complete: function() {
                mb.destroyloadingTable1();
            }
        });
    });
</script>